<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
<link rel="stylesheet" href="../../../.resources/report.css"
	type="text/css" />
<link rel="shortcut icon" href="../../../.resources/report.gif"
	type="image/gif" />
<title>VendingMachineItem.java</title>
<link rel="stylesheet" href="../../../.resources/prettify.css"
	type="text/css" />
<script type="text/javascript" src="../../../.resources/prettify.js"></script>
</head>
<body onload="window['PR_TAB_WIDTH']=4;prettyPrint()">
	<div class="breadcrumb" id="breadcrumb">
		<span class="right"><a href="../../../.sessions.html"
			class="el_session">Sessions</a></span><a href="../../../index.html"
			class="el_report">Vending Machine (2012-4-23 18:20:54)</a> &gt; <a
			href="../../index.html" class="el_group">Vending Machine</a> &gt; <a
			href="../index.html" class="el_bundle">src</a> &gt; <a
			href="index.html" class="el_package">default</a> &gt; <span
			class="el_source">VendingMachineItem.java</span>
	</div>
	<h1>VendingMachineItem.java</h1>
	<pre class="source lang-java linenums">/**
 * @author Vaishnavi Narayava, Weng-Keen Wong
 *
 * Class for items in the vending machine
 */
public class VendingMachineItem {

	// The name of the item
	private String name;

	// The price of the item
	private double price;

	// Exception message for when the price is less than zero
	private final static String PRICE_LESS_THAN_ZERO_MESSAGE = &quot;Price cannot be less than zero&quot;;
	
	/**
	 * Constructor which fills in the name and price of the item
	 * Precondition: price argument &gt;= 0
	 * Postcondition:  The name and price of the item is set to be the values in the arguments
	 * @param name The name of the item
	 * @param price The price of the item
	 * @throws VendingMachineException Thrown if price is less than zero
	 */
<span class="fc" id="L25">	public VendingMachineItem( String name, double price ) throws VendingMachineException {</span>
<span class="fc" id="L26">		this.name = name;</span>
<span class="fc bfc" id="L27" title="All 2 branches covered.">		if( price &lt; 0 ) {</span>
<span class="fc" id="L28">			throw new VendingMachineException(PRICE_LESS_THAN_ZERO_MESSAGE);</span>
		} else {
<span class="fc" id="L30">			this.price = price;</span>
		}
<span class="fc" id="L32">	}</span>
	
	/**
	 * Gets the name of the vending machine item
	 * @return The string corresponding to the name of the vending machine item
	 * Postcondition: the actual name of the item is returned
	 */
	public String getName() {
<span class="fc" id="L40">        return name;</span>
    }
    
    /**
     * Gets the price of the vending machine item
     * @return The price of the vending machine item in dollars
     * Postcondition: The actual price of the item is returned
     */
    public double getPrice() {
<span class="fc" id="L49">        return price;</span>
    }
}
</pre>
	<div class="footer">
		<span class="right">Created with <a
			href="http://www.eclemma.org/jacoco">JaCoCo</a> 0.5.6.201201232323
		</span>Vending Machine (2012-4-23 18:20:54)
	</div>
</body>
</html>